package com.yay.mashiro.yayclient.ui.clickgui.controls;

import java.awt.Color;

import org.lwjgl.input.Mouse;

import com.yay.mashiro.yayclient.Yay;
import com.yay.mashiro.yayclient.module.Value;
import com.yay.mashiro.yayclient.module.modules.render.ClickGui;
import com.yay.mashiro.yayclient.ui.clickgui.font.HanabiFonts;
import com.yay.mashiro.yayclient.ui.clickgui.panel.WindowPanel;
import com.yay.mashiro.yayclient.utils.Colors;
import com.yay.mashiro.yayclient.utils.PlayerUtils;

import ClassSub.Class246;

public class Mode {
	Value<String> value;
    int x;
    int y;
    private boolean readySelect;
    private boolean isSelectingMode;
    double ani;
    public static Value<String> renderingValue;
    public int valueOffset = 0;

    public Mode(Value value) {
        this.value = value;
    }

    public void draw(int n, int n2, int n3, int n4) {
        if (this.isSelectingMode) {
            renderingValue = this.value;
        }
//        if (renderingValue != null && renderingValue != this.value) {
//            return;
//        }
        boolean bl = ClickGui.theme.isCurrentMode("Light");
        float f = n2 - 5;
        float f2 = f + 7.0f;
        this.ani = Class246.getAnimationState(this.ani, this.isSelectingMode ? 20 * this.value.mode.size() : 20, 400.0);
        Class246.drawRoundedRect(n - 80, f, n - 20, (float)((double)f + this.ani), 2.0f, bl ? new Color(Colors.GREY.c).brighter().getRGB() : new Color(15, 15, 15).getRGB());
        Class246.drawRoundedRect(n - 80, f, n - 20, f + 20.0f, 2.0f, bl ? new Color(Colors.GREY.c).brighter().getRGB() : new Color(21, 21, 21).getRGB());
        Yay.getFontManager().usans15.drawString(this.value.mode.get(this.value.getCurrentMode()), n - 75, f2, -1);
        
        
        if (!this.isSelectingMode) {
            Yay.getFontManager().icon15.drawString(HanabiFonts.ICON_CLICKGUI_ARROW_UP, n - 32, n2 + 1, -1);
            if (Mouse.isButtonDown((int)0) && this.isHovering(n3, n4, n - 80, f, n - 20, f + 20.0f) && !this.readySelect) {
                this.readySelect = true;
            }
            if (!Mouse.isButtonDown((int)0) && this.readySelect) {
                this.isSelectingMode = true;
            }
        } else {
            Yay.getFontManager().icon15.drawString(HanabiFonts.ICON_CLICKGUI_ARROW_DOWN, n - 32, n2 + 1, -1);
            for (String string : this.value.mode) {
                if (string.equals(this.value.mode.get(this.value.getCurrentMode()))) continue;
                f2 += 20.0f;
                if (!(this.ani > (double)((f += 20.0f) - (float)n2 - 30.0f))) continue;
                if (Mouse.isButtonDown((int)0)) {
                    if (this.isHovering(n3, n4, n - 80, f, n - 20, f + 20.0f)) {
                        this.isSelectingMode = false;
                        this.readySelect = false;
//                        new Class76(this).start();
                        this.value.setCurrentMode(this.value.mode.indexOf(string));
                    } else {
                        for (Mode Mode : WindowPanel.modeValueMap.values()) {
//                            new Class196(this, Mode).start();
                        }
                    }
                }
                
                Yay.getFontManager().usans15.drawString(string, n - 75, f2, -1);
            }
        }
    }

    private boolean isHovering(int n, int n2, double d, double d2, double d3, double d4) {
        return ((double)n > d && (double)n < d3 && (double)n2 > d2 && (double)n2 < d4 ? 1 : 0) != 0;
    }

    static boolean access$002(Mode Mode, boolean bl) {
        Mode.isSelectingMode = bl;
        return Mode.isSelectingMode;
    }

    static boolean access$102(Mode Mode, boolean bl) {
        Mode.readySelect = bl;
        return Mode.readySelect;
    }
}
